import {createStore} from 'vuex'
import createPersistedState from 'vuex-persistedstate'

export default createStore({
    plugins:[createPersistedState({
        reducer:(state)=>{
            console.log(state);
            return {
                cityName:state.cityName,
                // userInformation:state.userInformation
            }
        },

    })],
    // 公共状态
    state:{
        cityName: '广州',
        isTabbarShow:true,
        userId:'',
        userName:'',
        userheadheight:'',
        userInformation:false
    },
    mutations:{
        changeCityName(state, cityName) {
            console.log(cityName);
            state.cityName = cityName
        },
        changeUserId(state,userId){
           state.userId=userId
        },
        changeUserName(state,userName){
            state.userName=userName
         },
         changeUserHeadHeight(state,userheadheight){
            state.userheadheight=userheadheight
         },
        hidden(state){
            state.isTabbarShow=false
        },
        show(state){
            state.isTabbarShow=true
        },
        handleState(state,value){
            state.userInformation=value
        }
    }
})